<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>预定<{$hotelrs.hotel1}>  <{$Think.SYS_SITENAME}></title>
<link href="__PUBLIC__/css/orderstyle.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/jsLibrary/Jslibary.js"></script>
</head>

<body>
<!--顶部-->

<include file="./Index/Tpl/Home/default/public/header.htm" />

<div class="containet">
    <div class="containet_left"></div>
    <div class="containet_cont"></div>
    <div class="containet_right"></div>
    <div class="frame">
        <form action="/order/view2" method="post" name="orderform" id="orderform">
         <div class="frame_content">
            <div class="frame_content_top"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;编辑订单</div>
        <div class="frame_content_list">
                <div class="list"><{$hotelrs.hotel1}></div>
                <input type="hidden" name="checkdatepflag" id="checkdatepflag" value="0">
                <div class="dd_jtxx">
                    <ul class="dd_list_name">
                        <li>房间名称：</li>
                        <li class="list_selert">
                            <select name="roomtypeid" id="roomtypeid">
                              <volist name="roomrs" id="vo">
                                <option       <if condition="$_GET['rid'] eq $vo['hotelroom0']"> selected </if>
                                 value="<{$vo.hotelroom0}>"><{$vo.hotelroom1}></option>
                              </volist>
                            </select>
                        </li>
                    </ul>
                    <ul class="dd_list_name">
                        <li>房间数量：</li>
                        <li class="list_selert">  
                            <select name="croomnum" id="croomnum" >
                              <php>for($i=1;$i<=20;$i++){</php><option value="<php> echo $i;</php>"><php> echo $i;</php>间</option><php> }</php>
                            </select>
                        </li>
                    </ul>
                </div>
          <div class="list_name">人数：</div>
          <div class="list_selert">                    <select name="chengrens" id="chengrens"  class="selert">
                      <php>for($i=1;$i<=30;$i++){</php><option value="<php> echo $i;</php>"><php> echo $i;</php></option><php> }</php>
                      
                    </select></div>
          
                    
             
            
          <div class="list_name">抵达时间：</div>
          <div class="list_selert"><select name="didianshijian" id="didianshijian"  class="selert">
                       <php>for($i=0;$i<=23;$i++){</php><option value="<php> echo $i;</php>:00"><php> echo $i;</php>:00</option><php> }</php>
                    </select></div>
               
            <div class="list_name">入住日期：</div> 
           <div class="list_text"><input type="text" class="selert2" name="startdate" id="startdate" onClick="javascript:cdate_show('startdate');" value="<{$tconfig.startdate}>" /></div> 
           <div class="list_txt">离店日期</div>
           <div class="list_text"><input type="text" onkeyup="return checkdateyoux();"  class="selert2" name="enddate" id="enddate" onClick="javascript:cdate_show('enddate');" value="<{$tconfig.enddate}>" /></div> 
                           
            </div>
            
<div class="frame2">
    <div class="list_name">价格明细：</div> <br><br /> 
    <div class="table_box" id="showsearchhtml">

    </div>
</div>
  
<div class="times" id="passnotehtml" style="display:none;"> &nbsp;&nbsp;&nbsp;&nbsp;很抱歉，部分日期内没有空余房间了，您可以 <font color="#294E5E">选择时间</font> 或 <font color="#294E5E">修改房型</font></div>      

<div class="box_2" id="totalpricenum" style="display:none;">
  <div class="gross">小计：</div><span id="sp_totalnum"></span>元</div>

<div class="box_3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;预订人信息</div>

<!--表单信息-->
<div class="input_frame">
  <div class="from_box">   
      <div class="list_left">会员名称</div>  
      <div class="list_midd"><input type="text" class="sty" name="userid" id="userid"  value="<{$Think.const.__USERNAME__}>" /></div  
     ><div class="list_left">可以兑换金额数</div>  
     <div class="list_midd"><input type="text" class="sty" readonly="readonly" name="duihuanje" id="duihuanje"  value="0" /> 是否兑换<input type="checkbox" id="isduihuan" name="isduihuan" checked="checked" value="1"></div>
     <div class="list_left"></div> 
     <div class="list_midd"> </div>
     <div class="list_left">电子邮箱</div>  
     <div class="list_midd"><input type="text" class="sty" name="useremail" id="useremail" /></div>  
    <div class="list_left">确认邮箱</div>
    <div class="list_midd"><input type="text" class="sty"  name="reuseremail" id="reuseremail"/></div>  
    <div class="list_left">预订人姓名</div>
    <div class="list_midd"><input type="text" class="sty" name="username" id="username" /></div>  
    <div class="list_left">入住人姓名</div>
    <div class="list_midd"><input type="text" class="sty" name="zhuname" id="zhuname" /> </div>  
    <div class="list_left">来自</div>
    <div class="list_midd"><input  type="text" class="sty" name="formarea" id="formarea" /></div>  
    <div class="list_left">联系电话</div>
    <div class="list_midd"><input type="text" class="sty" name="tel" id="tel" /></div>
    
    <div class="list_left">其它说明</div>     
    <div class="fowllow"><textarea name="othersuom" id="othersuom" cols="35" rows="8"></textarea></div> 
    <div class="yzm">输入验证码</div>
      <div class="veri1"><input type="text" class="veri" name="verify" id="verify" /></div> 
     <div class="numbers"><img id="checkcode" src="/common/verify" /></div> 
     <div class="veri1_number"><span id="reloadcm" style="cursor:pointer;">换一个</a></div>
  </div>
   
  <!--表单说明-->
  <div class="explan_box">
      <div class="explan ">
        <span style="width:auto; float:left;"><font color="#FF0000">你有积分数:</span>
         <span id="havejf"><{:uc_user_getcredit(1, __USERID__, 'credit')}></span></font>
      </div>
      <div class="explan "><font color="#FF0000">单位：人民币元</font></font></div>
      <div class="explan "><font>人民币:元</font></div>
      <div class="explan">*请输入正确的邮箱地址！</div>
      <div class="explan">*</div> 
      <div class="explan"></font></div>
      <div class="explan"> 可以填写多个入住人姓名</div>
      <div class="explan">最后是手机号，以便及时联系和接收订单信息</div> 
      <div class="explan2"></div>
   </div> 
   
</div>
    
    
     <div class="box_2" id="overdnumjie"> 
        <div class="gross">总计：</div>
        <div style="width:auto; line-height:40px; float:left;"><span id="overtotalnum"></span>元 - 积分兑换金额</div>
        <div style="width:auto; line-height:40px; float:left;"><span id="jifendiyongje"></span>元 = </div><span id="orderje"> </span>元
     </div> 
     <input type="hidden" id="orderjingje" name="orderjingje" value="0">
     
       <input type="hidden" id="hid" name="hid" value="<{$Think.get.hid}>">
        <input type="hidden" id="zfbl" name="zfbl" value="100">
         <input type="hidden" id="proname" name="proname" value="<{$hotelrs.hotel1}>">
     </form>
    </div> 

</div>
<div class="foot">
  </div>
  <div class="btn"><img src="__PUBLIC__/images/btn.jpg" style="cursor:pointer;" name="mysubmit" id="mysubmit" /></div>

<script src="__PUBLIC__/jsLibrary/cdate_py_z.js"></script>
<script language="javascript">
$(document).ready(function(){
	$("#croomnum").bind("change",function(){
		checkdateyoux();
	});
	$("#isduihuan").bind("click",function(){
		checkdateyoux();
	});
	
	$("#roomtypeid").bind("change",function(){
		window.location.href="/order/view1-hid-<{$Think.get.hid}>-rid-"+$("#roomtypeid").val();
		
	});
	
	$("#reloadcm").bind("click",function(){
		$("#checkcode").attr("src","/common/verify-"+Math.random());
	});
	
	
	//验证表单
	$("#mysubmit").bind("click",function(){
		
		dd=$("#checkdatepflag").val();
		if(dd!="1"){
			alert("请选择正确的时间入住");
			$("#checkdatepflag").focus();
			return false;	
		}
		if(!nzeletype("useremail","请输入正确的电子邮件","email")) return false;
		if(!nzeletype("reuseremail","请输入正确的电子邮件","email")) return false;
		if($("#useremail").val()!=$("#reuseremail").val()){
			alert("您两次的邮件地址不一样，请重新输入");
			$("#reuseremail").focus();
			return false;	
		}
		
		
		checkcode=$("#verify").val();
		
		if(checkcode.length!=4){
			alert("请输入正确的验证码.");
			$("#verify").focus();
			return false;
		}
		
		
		
		
		
		$("#orderform").submit();
		
	}); 
	
	 checkdateyoux();//初始化值
	
});

 
function checkdateyoux(){
		
		$("#passnotehtml").hide();
		$("#totalpricenum").hide();
		//$("#duihuanje").val(0);
		$("#overdnumjie").hide();
		
		
		var startdate=$("#startdate").val();
		if(!startdate.match(/^[\d]{4}\-[\d]{1,2}\-[\d]{1,2}$/)){
			alert("请选择正确的入住时间");
			$("#startdate").focus();
			return false;	
		}
		
		var enddate=$("#enddate").val();
		if(!startdate.match(/^[\d]{4}\-[\d]{1,2}\-[\d]{1,2}$/)){
			alert("请选择正确的离店时间");
			$("#enddate").focus();
			return false;	
		}
		if(enddate<=startdate){
			alert("离店时间不能小于入住时间");
			$("#enddate").focus();
			return false;	
		}
		
		
		//获取实时的房间信息
		startdate=startdate.replace(/\-/g,"_");
		enddate=enddate.replace(/\-/g,"_");
		$.ajax({
		  url: "/hotelroom/checkdateyoux-hid-<{$Think.get.hid}>-rid-<{$Think.get.rid}>-startdate-"+startdate+"-enddate-"+enddate+"-n-"+$("#croomnum").val(),
		  cache: true,
		  beforeSend: function(){
			  $("#showsearchhtml").html("正在查询请稍后.....");
		  },
		  success: function(html){
			
			temp=html.replace(/\{[\d]+\}/g,"");
			temp=temp.replace(/\@[\d]+\@/g,"")
			$("#showsearchhtml").html(temp);
			//如果有满房提示他重新选择
			if(html.indexOf("满房")>0){
					$("#passnotehtml").show("slow");
			}else{
				$("#totalpricenum").show();
				$("#checkdatepflag").val("1");//是否是选择了正确的时间和是否有房
			}
			
			
			//计算总的价格
			totalnum=getkuohaostr(html,/\{([\d]+)\}/);
			zfbl=getkuohaostr(html,/\@([\d]+)\@/);
			$("#sp_totalnum").html(totalnum);
			$("#zfbl").val(zfbl);
			//计算积分兑换后的价
			
			
			if($("#isduihuan").attr("checked")=="checked"){
				xfsjfnumdy1jenum=<{$SYS_config.xfsjfnumdy1jenum}>;
				thistnum=parseInt(totalnum)*<{$SYS_config.maxjifenduije}>;
				jingbi=$("#havejf").html();//拥有的金币数
				jingbinum=parseInt(jingbi);
				if(jingbinum/xfsjfnumdy1jenum>thistnum){
					maydinum=	parseInt(thistnum);
				}else{
					maydinum=parseInt(jingbinum/xfsjfnumdy1jenum);	
				}
				
				$("#duihuanje").val(maydinum);
				$("#overdnumjie").show();
				$("#overtotalnum").html(totalnum);
				$("#jifendiyongje").html($("#duihuanje").val());
				$("#orderje").html(totalnum-maydinum);
				$("#orderjingje").val(totalnum-maydinum);
			}
			
			
		  }
		 
		});

 }

</script>


</body>
</html>
